# !/usr/bin/python
# -*- coding: UTF-8 -*-
import json
import datetime
import redis

if __name__ == '__main__':
    # 链接 redis
    redis_client = redis.Redis(host='localhost', port=6379)
    # 加载数据开始
    weibo_posts_path = "D:\\mark-workspace\\corpus_data\\weibo\\CommentRInteractionDataset\\Posts.json"
    weibo_comments_path = "D:\\mark-workspace\\corpus_data\\weibo\\CommentRInteractionDataset\\Comments.json"
    with open(weibo_posts_path, encoding="utf-8") as f:
        post_json_str = f.read()

    posts_json = json.loads(post_json_str)
    # 加载数据结束
    len_num = len(posts_json)

    not_single_retweet_id_count = 0

    posts_no_comments_count = 0

    posts_has_comments_count = 0

    # results = [item for item in posts_json if item['is_retweet'] is True]

    for item_single in posts_json:
        # print("key1: {0}".format(item_single['retweet_id']))
        if item_single['comments_count'] > 0:
            posts_has_comments_count = posts_has_comments_count + 1
        else:
            posts_no_comments_count = posts_no_comments_count + 1

        # result_get = [item for item in results if item['retweet_id'] == item_single['retweet_id']]
        # if len(result_get) > 1:
        #     not_single_retweet_id_count = not_single_retweet_id_count + 1
        #     print(not_single_retweet_id_count)
        #     # print("key2: {0}".format(item_single['retweet_id']))
        #     # exit()
        # else:
        #     pass
        #     continue

    print(" +++++++++ below is result ++++++++++")

    # print("all len_num :  {0} ! ".format(len_num))
    #
    # print("retweet_num :  {0} ! ".format(len(results)))
    #
    # print("the same retweet_id count is : {0} ! ".format(not_single_retweet_id_count))

    print("not_comments_sum :  {0} ! ".format(posts_no_comments_count))

    print("comments_sum :  {0} ! ".format(posts_has_comments_count))
